package club.gskj.gulimall.ware.service;

import club.gskj.common.to.mq.OrderTo;
import club.gskj.common.to.mq.StockLockedTo;
import club.gskj.gulimall.ware.vo.SkuHasStockVo;
import club.gskj.gulimall.ware.vo.WareSkuLockVo;
import com.baomidou.mybatisplus.extension.service.IService;
import club.gskj.common.utils.PageUtils;
import club.gskj.gulimall.ware.entity.WareSkuEntity;

import java.util.List;
import java.util.Map;

/**
 * 商品库存
 *
 * @author 康纳-connor
 * @email 2417039231@gmail.com
 * @date 2021-02-07 10:08:31
 */
public interface WareSkuService extends IService<WareSkuEntity> {

    PageUtils queryPage(Map<String, Object> params);

    /***
     *
     * @param skuId   商品id
     * @param wareId  仓库id
     * @param skuNum  库存数量
     * @return void
     * @author 康纳-connor
     * @creed: Talk is cheap,show me the code
     * @date 21.2.7 15:23
     * @Description 给对应商品添加库存
     */
    void addStock(Long skuId, Long wareId, Integer skuNum);

    /**
     * 查询 sku是否保存库存
     */
    List<SkuHasStockVo> hasStock(List<Long> skuIds);

    /***
     *  锁定指定订单商品库存信息
     * @param wareSkuLockVo
     * @return
     */
    Boolean orderLockStock(WareSkuLockVo wareSkuLockVo);

    /***
     *  解锁库存
     * @param to
     */
    void unLock(StockLockedTo to);

    /**
     * 根据订单解锁信息，解锁库存
     *
     * @param orderTo
     */
    void unLock(OrderTo orderTo);
}

